package com.burstly.jackson.map.ext;

import com.burstly.jackson.map.DeserializationConfig;
import com.burstly.jackson.map.DeserializerProvider;
import com.burstly.jackson.map.JsonDeserializer;
import com.burstly.jackson.map.JsonSerializer;
import com.burstly.jackson.map.SerializationConfig;
import com.burstly.jackson.map.deser.std.StdDeserializer;
import com.burstly.jackson.map.util.Provider;
import com.burstly.jackson.type.JavaType;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;

public class OptionalHandlerFactory
{
  private static final String CLASS_NAME_DOM_DOCUMENT = "org.w3c.dom.Node";
  private static final String CLASS_NAME_DOM_NODE = "org.w3c.dom.Node";
  private static final String DESERIALIZERS_FOR_JAVAX_XML = "org.codehaus.jackson.map.ext.CoreXMLDeserializers";
  private static final String DESERIALIZERS_FOR_JODA_DATETIME = "org.codehaus.jackson.map.ext.JodaDeserializers";
  private static final String DESERIALIZER_FOR_DOM_DOCUMENT = "org.codehaus.jackson.map.ext.DOMDeserializer$DocumentDeserializer";
  private static final String DESERIALIZER_FOR_DOM_NODE = "org.codehaus.jackson.map.ext.DOMDeserializer$NodeDeserializer";
  private static final String PACKAGE_PREFIX_JAVAX_XML = "javax.xml.";
  private static final String PACKAGE_PREFIX_JODA_DATETIME = "org.joda.time.";
  private static final String SERIALIZERS_FOR_JAVAX_XML = "org.codehaus.jackson.map.ext.CoreXMLSerializers";
  private static final String SERIALIZERS_FOR_JODA_DATETIME = "org.codehaus.jackson.map.ext.JodaSerializers";
  private static final String SERIALIZER_FOR_DOM_NODE = "org.codehaus.jackson.map.ext.DOMSerializer";
  public static final OptionalHandlerFactory instance = new OptionalHandlerFactory();

  private boolean doesImplement(Class<?> paramClass, String paramString)
  {
    boolean bool = true;
    for (Object localObject = paramClass; ; localObject = ((Class)localObject).getSuperclass())
    {
      if (localObject == null)
        bool = false;
      while ((((Class)localObject).getName().equals(paramString)) || (hasInterface((Class)localObject, paramString)))
        return bool;
    }
  }

  private boolean hasInterface(Class<?> paramClass, String paramString)
  {
    boolean bool = true;
    Class[] arrayOfClass = paramClass.getInterfaces();
    int i = arrayOfClass.length;
    int j = 0;
    int k;
    if (j >= i)
      k = arrayOfClass.length;
    for (int m = 0; ; m++)
    {
      if (m >= k)
        bool = false;
      while (hasInterface(arrayOfClass[m], paramString))
      {
        do
          return bool;
        while (arrayOfClass[j].getName().equals(paramString));
        j++;
        break;
      }
    }
  }

  private boolean hasInterfaceStartingWith(Class<?> paramClass, String paramString)
  {
    boolean bool = true;
    Class[] arrayOfClass = paramClass.getInterfaces();
    int i = arrayOfClass.length;
    int j = 0;
    int k;
    if (j >= i)
      k = arrayOfClass.length;
    for (int m = 0; ; m++)
    {
      if (m >= k)
        bool = false;
      while (hasInterfaceStartingWith(arrayOfClass[m], paramString))
      {
        do
          return bool;
        while (arrayOfClass[j].getName().startsWith(paramString));
        j++;
        break;
      }
    }
  }

  private boolean hasSupertypeStartingWith(Class<?> paramClass, String paramString)
  {
    boolean bool = true;
    Class localClass = paramClass.getSuperclass();
    if (localClass == null);
    for (Object localObject = paramClass; ; localObject = ((Class)localObject).getSuperclass())
    {
      if (localObject == null)
        bool = false;
      while (hasInterfaceStartingWith((Class)localObject, paramString))
      {
        do
          return bool;
        while (localClass.getName().startsWith(paramString));
        localClass = localClass.getSuperclass();
        break;
      }
    }
  }

  private Object instantiate(String paramString)
  {
    try
    {
      Object localObject = Class.forName(paramString).newInstance();
      return localObject;
    }
    catch (Exception localException)
    {
      return null;
    }
    catch (LinkageError localLinkageError)
    {
      label13: break label13;
    }
  }

  public JsonDeserializer<?> findDeserializer(JavaType paramJavaType, DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider)
  {
    Class localClass = paramJavaType.getRawClass();
    String str1 = localClass.getName();
    String str2;
    Object localObject;
    if (str1.startsWith("org.joda.time."))
    {
      str2 = "org.codehaus.jackson.map.ext.JodaDeserializers";
      localObject = instantiate(str2);
      if (localObject == null)
        break label152;
    }
    else
    {
      label40: 
      do
      {
        return null;
        if ((str1.startsWith("javax.xml.")) || (hasSupertypeStartingWith(localClass, "javax.xml.")))
        {
          str2 = "org.codehaus.jackson.map.ext.CoreXMLDeserializers";
          break;
        }
        if (doesImplement(localClass, "org.w3c.dom.Node"))
          return (JsonDeserializer)instantiate("org.codehaus.jackson.map.ext.DOMDeserializer$DocumentDeserializer");
      }
      while (!doesImplement(localClass, "org.w3c.dom.Node"));
      return (JsonDeserializer)instantiate("org.codehaus.jackson.map.ext.DOMDeserializer$NodeDeserializer");
    }
    Collection localCollection = ((Provider)localObject).provide();
    Iterator localIterator1 = localCollection.iterator();
    label152: StdDeserializer localStdDeserializer1;
    do
    {
      if (!localIterator1.hasNext())
      {
        Iterator localIterator2 = localCollection.iterator();
        if (!localIterator2.hasNext())
          break label40;
        StdDeserializer localStdDeserializer2 = (StdDeserializer)localIterator2.next();
        if (!localStdDeserializer2.getValueClass().isAssignableFrom(localClass))
          break;
        return localStdDeserializer2;
      }
      localStdDeserializer1 = (StdDeserializer)localIterator1.next();
    }
    while (localClass != localStdDeserializer1.getValueClass());
    return localStdDeserializer1;
  }

  public JsonSerializer<?> findSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType)
  {
    Class localClass = paramJavaType.getRawClass();
    String str1 = localClass.getName();
    if (str1.startsWith("org.joda.time."));
    Object localObject;
    for (String str2 = "org.codehaus.jackson.map.ext.JodaSerializers"; ; str2 = "org.codehaus.jackson.map.ext.CoreXMLSerializers")
    {
      localObject = instantiate(str2);
      if (localObject != null)
        break label89;
      return null;
      if ((!str1.startsWith("javax.xml.")) && (!hasSupertypeStartingWith(localClass, "javax.xml.")))
        break;
    }
    if (doesImplement(localClass, "org.w3c.dom.Node"))
      return (JsonSerializer)instantiate("org.codehaus.jackson.map.ext.DOMSerializer");
    return null;
    label89: Collection localCollection = ((Provider)localObject).provide();
    Iterator localIterator1 = localCollection.iterator();
    Iterator localIterator2;
    if (!localIterator1.hasNext())
      localIterator2 = localCollection.iterator();
    Map.Entry localEntry2;
    do
    {
      if (!localIterator2.hasNext())
      {
        return null;
        Map.Entry localEntry1 = (Map.Entry)localIterator1.next();
        if (localClass != localEntry1.getKey())
          break;
        return (JsonSerializer)localEntry1.getValue();
      }
      localEntry2 = (Map.Entry)localIterator2.next();
    }
    while (!((Class)localEntry2.getKey()).isAssignableFrom(localClass));
    return (JsonSerializer)localEntry2.getValue();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.jackson.map.ext.OptionalHandlerFactory
 * JD-Core Version:    0.6.2
 */